(function () {
    var overrideCtx = {};
    overrideCtx.Templates = {};
    //overrideCtx.Templates.Fields = { 'Title': { 'View': CPublishImage } };
    overrideCtx.Templates.Fields = { 'Author': { 'View': CAuthorName } };
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();

function CPublishImage(ctx) {
    var imageurl = ctx.CurrentItem.PublishingPageIcon;
    var imgUrl = '';
    if (imageurl != null && $(imageurl).find('img').length > 0 && $(imageurl).find('img').attr('src') != "") {
        imgUrl = $(imageurl).find('img').attr('src');
    }
    else {
        imgUrl = '/teams/OurVoiceHN/Style Library/Images/default_image.gif';
    }
    var ret = "<div class='imgheader'>" + "<img class='img-responsive' src='" + imgUrl + "'</div>" + ctx.CurrentItem.Title;
    return ret;
}

function CAuthorName(ctx) {
    var authorName = ctx.CurrentItem.AuthorName;
    var author = ctx.CurrentItem.Author;

    if (authorName !== null) {
        return "<span style='color:#0072c6'>" + authorName + "</span>";
    } else {
        return "<span style='color:#0072c6'>" + author + "</span>";;
    }
}